<?php

namespace App\Console\Commands;

use App\Console\Commands\Common\CommonCommand;
use App\Models\User\User;

class CheckMember extends CommonCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'checkmember';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        //Log::info('checkmember__construct run...');
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle() {

        //主网站
        User::where('is_member',1)
            ->where('expire_time','<=',date('Y-m-d H:i:s'))
            ->update(['type'=>'normal','is_member'=>2]);

        //副网站
        User::where('ex_is_member',1)
            ->where('ex_expire_time','<=',date('Y-m-d H:i:s'))
            ->update(['ex_type'=>'normal','ex_is_member'=>2]);

        return 0;
    }
}
